/**
 * 
 */
package com.sesame.daoimpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.sesame.dao.AnswerDAO;
import com.sesame.domain.Answer;

/**
 * @author shubeta
 *
 */
public class AnswerDAOImpl extends SqlMapClientDaoSupport implements AnswerDAO {

    public void addAnswer(Answer answer) {
        getSqlMapClientTemplate().insert("addAnswer", answer);
    }

    public void deleteAnswerById(Integer id) {
        getSqlMapClientTemplate().delete("deleteAnswerById", id);
    }
    
    public void deleteAnswerByNickName(String nickName) {
    	getSqlMapClientTemplate().delete("deleteAnswerByNickName", nickName);
    }
    
    @SuppressWarnings("unchecked")
    public List<Answer> getAllAnswer() {
        return (List<Answer>) getSqlMapClientTemplate().queryForList("getAllAnswer");
    }

    public Answer getAnswerByNickName(String nickName) {
        return (Answer) getSqlMapClientTemplate().queryForObject("getAnswerByNickName",
                nickName);
    }

    public void updateAnswer(Answer answer) {
        getSqlMapClientTemplate().update("updateAnswer", answer);
    }

}
